<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:include page="/WEB-INF/templateFrontoffice/header.jsp"/>
<script src="<c:url value='/javascript/jquery.tablesorter.js'/>"></script>
<script src="<c:url value='/javascript/jquery.tablesorter.custom.js'/>"></script>
  <div id="container">
    <div id="top">
      <span id="arianne">
          <a href="<c:url value='/'/>">Accueil</a> > 
          <a href="<c:url value='/offre/liste'/>">Liste des offres</a>
      </span>
      <br/>
      <div id="mainlarge">
        <h2>Liste des offres </h2>
        <p class="error">${error}</p>


        <table id="myTable" class="CSSTableGenerator a_black format_listeTransaction">
            <thead>
                <tr>
                    <th>
                        Société
                        <img class="up" src="<c:url value='/images/arrow_up.png'/>" alt="up"/>
                        <img class="down" src="<c:url value='/images/arrow_down.png'/>" alt="down"/>
                    </th>
                    <th>
                        Vendeur
                        <img class="up" src="<c:url value='/images/arrow_up.png'/>" alt="up"/>
                        <img class="down" src="<c:url value='/images/arrow_down.png'/>" alt="down"/>
                    </th>
                    <th>
                        Date émission
                        <img class="up" src="<c:url value='/images/arrow_up.png'/>" alt="up"/>
                        <img class="down" src="<c:url value='/images/arrow_down.png'/>" alt="down"/>
                    </th>
                    <th>
                        Date échéance
                        <img class="up" src="<c:url value='/images/arrow_up.png'/>" alt="up"/>
                        <img class="down" src="<c:url value='/images/arrow_down.png'/>" alt="down"/>
                    </th>
                    <th>
                        Type vente
                        <img class="up" src="<c:url value='/images/arrow_up.png'/>" alt="up"/>
                        <img class="down" src="<c:url value='/images/arrow_down.png'/>" alt="down"/>
                    </th>
                    <th>
                        Prix
                        <img class="up" src="<c:url value='/images/arrow_up.png'/>" alt="up"/>
                        <img class="down" src="<c:url value='/images/arrow_down.png'/>" alt="down"/>
                    </th>
                    <c:if test="${sessionScope.user != null }">
	                    <th style="width:150px">
	                        Acheter
	                        <img class="up" src="<c:url value='/images/arrow_up.png'/>" alt="up"/>
	                        <img class="down" src="<c:url value='/images/arrow_down.png'/>" alt="down"/>
	                    </th>
                    </c:if>
                </tr>
            </thead>
            <tbody>
                <c:forEach var="vente" items="${ventes}" varStatus="status">
                <tr>
                    <td>
                    	<a href="<c:url value='/societe?id=${vente.portefeuille.toArray()[0].entrepriseOrigine.idEntreprise}'/>">
                    		<c:out value="${vente.portefeuille.toArray()[0].entrepriseOrigine.nom}"/>
                    	</a>
                    </td>
                    <td><c:out value="${vente.vendeur.nom}"/></td>
                    <td><fmt:formatDate value="${vente.date_emission}" pattern="dd/MM/yyyy"/></td>
                    <td><fmt:formatDate value="${vente.date_echeance}" pattern="dd/MM/yyyy"/></td>
                    <td>Vente</td>
                    <td><c:out value="${vente.prix}"/></td>
                    <c:if test="${sessionScope.user != null }">
                    	<td style="text-align : center;">
                    		<a href="<c:url value='/action/acheter?idvente=${vente.idOffreDeVente}'/>">
                    			<img src="<c:url value='/images/carte-credit-visa-icone-4092-32.png'/>" alt=""/>
                    		</a>
                    	</td>
                    </c:if>
                </tr>
                </c:forEach>
                
                <c:forEach var="enchere" items="${encheres}" varStatus="status">
                <tr>
                    <td>
                    	<a href="<c:url value='/societe?id=${enchere.portefeuille.toArray()[0].entrepriseOrigine.idEntreprise}'/>">
                    		<c:out value="${enchere.portefeuille.toArray()[0].entrepriseOrigine.nom}"/>
                    	</a>
                    </td>
                    <td><c:out value="${enchere.vendeur.nom}"/></td>
                    <td><fmt:formatDate value="${enchere.date_emission}" pattern="dd/MM/yyyy"/></td>
                    <td><fmt:formatDate value="${enchere.date_echeance}" pattern="dd/MM/yyyy"/></td>
                    <td>Echère</td>
                    <td><c:out value="${enchere.prixEmission}"/></td>
                    <c:if test="${sessionScope.user != null }">
                    	<td style="text-align: center">
                    		<a href="<c:url value='/action/acheter?idvente=${enchere.idOffreDeVente}'/>">
                    			<img src="<c:url value='/images/carte-credit-visa-icone-4092-32.png'/>" alt=""/>
                    		</a>
                    	</td>
                    </c:if>
                </tr>
                                    
                </c:forEach>
            </tbody>
        </table>
        <br/>
      </div>
    <!--end bottom-->
  </div>
  </div>
<jsp:include page="/WEB-INF/templateFrontoffice/footer.jsp"/>